<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div></div>
    <script src="/xuni/bundle.js"></script>
    <script>
        // var templateStr = "今天星期{{day}}";
        // var data = {
        //     day: "天",
        // }

        // 一维数组
        // var templateStr = `
        //     <ul>
        //         {{#arr}}
        //         <li>
        //             {{.}}
        //         </li>
        //         {{/arr}}
        //     </ul>
        // `;

        // var data = {
        //     arr: ["a", "b", "c"],
        // }

        // 嵌套数组
        var templateStr = `
            <ul>
                {{#arr}}
                <li>
                    姓名：{{name}}
                    <ol>
                        {{#hobbies}}
                            <li>{{.}}</li>
                        {{/hobbies}}
                    </ol>
                </li>
                {{/arr}}
            </ul>
        `;

        var data = {
            arr: [{
                    name: '小明',
                    hobbies: ["第一个", "第二个"]
                },
                {
                    name: '小红',
                    hobbies: ["第三个", "第四个"]
                },
                {
                    name: '小强',
                    hobbies: ["第五个", "第六个"]
                },
            ]
        }
        var domStr = templateEngine.render(templateStr, data);

        var div = document.querySelector("div");
        div.innerHTML = domStr;
    </script>
</body>

</html>